1.1 TCP packet format

Field

packet length

command

byte

2

2

Description:

1.       This packet is a fixed header for all packets that use TCP transport protocol.

2.       Each packet cannot more than 9*1024 bytes.

 

1.2 TCP packet extension format

Field

packet length

command

Extended data

byte

2

2

 

1.3 UDP packet format

 

Field

Udp version

command

byte

4

2

value

LOCAL_UDP_VERSION

 

 

Description:

1.       The packet is a fixed header for all packets using the UDP transport protocol.

2.       This packet is generally used to initiate communication to all lower computers.

 

1.4 UDP packet extension format

Field

packet length

command

Extended data

Extended data

byte

4

2

15

 

value

LOCAL_UDP_VERSION

 

 

Description

1.  The lower computer uses the device ID in the data packet to compare with the device ID of the lower computer. If the IDs are equal, the packet is parsed and processed, otherwise the packet is dropped.

 

1.5 The error code respond.

Field

packet length

command

Error Code

btye

2

2

2

value

6

kErrorAnswer

Description

1.       After the lower computer has an error, the upper computer can be notified by sending the data packet.

2.       After the upper computer error, the lower computer can be notified by sending the data packet.

3.       After receiving the error code, the lower computer will return to the state that the TCP connection has just been established.

1.       see enum ErrorCode .

 

1.6 TCP heartbeat package.

1.     TCP heartbeat package request.

Field

packet length

command

byte

2

2

value

4

kTcpHeartbeatAsk

Description

 

When a heartbeat packet is sent, there is no data response.

 

The upper computer should send this command packet to the lower computer to keep the heartbeat of the connection when no data is sent to the lower computer for more than 30 seconds. The lower computer judges according to 60 seconds. If the upper computer does not send any data to the lower computer for more than 60 seconds, the lower computer actively disconnects the TCP connection.

 

2.     TCP heartbeat package response.

Field

packet length

command

byte

2

2

value

4

kTcpHeartbeatAnswer

Description

When the lower computer sends more than 30 seconds without any data to the upper computer, it sends the command packet to the upper computer to maintain the connection.